package com.gitee.hljdrl.ffkit.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.gitee.hljdrl.ffkit.bean.FFKitLink;
import com.gitee.hljdrl.ffkit.databinding.FfkitAppHomeAdapterItemBinding;
import com.gitee.hljdrl.ffkit.util.FFKitUtil;

import java.util.List;

public class FFKitAdapter extends BaseRvAdapter<FFKitLink, FfkitAppHomeAdapterItemBinding> {

    public FFKitAdapter(Context context, List<FFKitLink> links) {
        super(context, links);
    }

    @Override
    public ViewHolder getViewHolder(@NonNull ViewGroup parent, int viewType) {
        FfkitAppHomeAdapterItemBinding itemBinding = FfkitAppHomeAdapterItemBinding.inflate(getLayoutInflater());
        return new ViewHolder(itemBinding);
    }

    @Override
    public void onBindItemViewData(FfkitAppHomeAdapterItemBinding itemBinding, FFKitLink data, int position) {
        itemBinding.itemPanel.setBackgroundColor(data.color);
        itemBinding.tvTitle.setText(FFKitUtil.string("name: ", data.name));
        itemBinding.tvDesc.setText(FFKitUtil.string("desc: ", data.desc));
        itemBinding.tvTitle.setTextColor(data.textColor);
        itemBinding.tvDesc.setTextColor(data.textColor);
        itemBinding.btnOpen.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onItemClickListener != null) {
                    onItemClickListener.onItemClick(view, position, data);
                }
            }
        });
    }


}
